import type { UploadRequestOptions } from 'element-plus'
import { ElLoading } from "element-plus";
import { http } from '../utils'
export const upload = async (file: any, func: Function) => {
    console.log(file, 'file');

    let loading = null;
    try {
        loading = ElLoading.service({
            lock: true,
            text: 'Loading',
            background: 'rgba(0, 0, 0, 0.7)',
        })
        const formData = new FormData()
        formData.append('file', file)
        let res = await http.post('/user-account/album', file, {
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        })
        func(res)
    } finally {
        loading && loading.close();
    }

} 